

<template>
  <div>
      <el-form
        ref="loginFormRef"
        :model="loginForm"
        class="login_form"
        label-width="0"
      >
        <el-form-item prop="username">
          <el-input
            class="login-input"
            autoComplete="on"
            v-model="loginForm.username"
            placeholder="请输入用户名"
          ><i
            slot="prefix"
            style="position: absolute; right: -1.5vw; top: 0.7vh"
          >
            <img
              style="width: 1.2vw; height: 3vh"
              src="./img/login-user.png"
            />
          </i>
          </el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input
            autoComplete="on"
            type="password"
            class="login-input"
            placeholder="请输入密码"
            v-model="loginForm.password"
            @keyup.enter.native="login"
          >
            <i
              slot="prefix"
              style="position: absolute; right: -1.5vw; top: 0.7vh"
            >
              <img
                style="width: 1.2vw; height: 3vh"
                src="./img/login-pswd.png"
              />

            </i>
          </el-input>
        </el-form-item>
        <el-form-item class="btn-box">
          <el-button class="login-btn" @click="login">登 录</el-button>
        </el-form-item>
      </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loginForm: {
        username: "",
        password: "",
      },
    };
  },
  methods: {
    login() {
      //
      const loading = this.$loading({
        lock: true,
        text: '登录中,请稍后。。。',
        spinner: "el-icon-loading"
      });
      this.$store.dispatch("LoginByUsername", this.loginForm).then((res) => {
        loading.close();
        // if (res.password_day && res.password_day <= 3) {
        //   let password_tilte = "您的密码已经过期，请尽快修改密码";
        //   if (res.password_day > 0) {
        //     password_tilte = '您的密码还有' + res.password_day + '天过期，请尽快修改密码';
        //   }
        //   this.$alert(password_tilte, '提示', {
        //     confirmButtonText: '确定',
        //     callback: () => {
        //       this.$router.push({path: "/userInfo", query: {type: "password"}});
        //     }
        //   });
        // } else {
          this.$router.push({path: "/"});
        // }
      }).catch(() => {
        loading.close();
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.login-container {
  background: url("./img/login-background.png");
  background-size: cover;
  height: 100%;
  width: 100%;

  .login-top {
    position: absolute;
    left: 50%;
    top: -27%;
    transform: translate(-50%, -50%);
    width: 600px;
    color: #ffffff;
    font-size:2vw;
    text-align: center;

    .login-title {
      font-weight: 600;
      margin-bottom: 0px;
			background: linear-gradient(0deg, #87CEFF 0%, #E4F6FF 100%);
      // background-image: -webkit-linear-gradient(bottom, #9fe2ff, #5da4fc);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    .login-subhead {
      margin-top: 15px;
      font-size: 1.5vw
    }
  }

  .login-box {
		width: 32vw;
		height: 40vh;
		background: rgba(0,35,104,.4);
    border-radius: 3px;
    background-size: cover;
    position: absolute;
    left: 50%;
    top: 58%;
    transform: translate(-50%, -50%);
    box-shadow: 0px 0px 3px black;

    /deep/ .el-input__inner {
      height: 0;
      line-height: 5.7vh;
      padding: 2vh 0;
      background-clip: content-box;
    }
    /deep/ input.el-input__inner::first-line{
      color: #fff;
      font-size: 0.9vw;


    }
    .login_form {
      width: 100%;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      align-items: center;
      box-sizing: border-box;
      position: absolute;
      bottom: 2.5vh;
      color: #fff;

      .login-input {
				width: 21vw;
				height: 5.7vh;
				line-height: 5.7vh;
				background: rgba(0,0,0,.3);
				border: 1px solid #3E5576;
				box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.35);
				border-radius: 3px;
				padding-left:2.5vw;
				box-sizing: border-box;
				margin-top:2vh;
				font-size: 0.87vw;
      }

      input:-webkit-autofill {
        -webkit-text-fill-color: #FFF
      }
    }

    .btn-box {
      width: 100%;
      display: flex;
      justify-content: space-between;
      .login-btn {
				color:#fff;
        width: 21vw;
        height: 5.6vh;
        background: rgba(9,59,129,.7);
        border-radius: 3px;
				border: 0;
				font-size:0.98vw;
				font-family: Microsoft YaHei;
				margin-top:2vh;
				box-shadow: 0px 1px 9px #011d59;
      }
    }
    .login-boxbg{
      z-index: -1;
      position: absolute;
      top: -24px;
      left: -15px;

    }
  }
	.line{
		width:32vw;
		height: 2px;
		display: block;
		position: absolute;
		left: 50%;
		top: 0%;
		transform: translate(-50%, -50%);
		background: linear-gradient(
			to right,
			rgba(0, 0, 0, .3) 0%,
			rgba(0, 0, 0, .3) 10%,
			rgba(20, 114, 202, 0.7) 20%,
			rgba(34, 145, 211, 0.7) 40%,
			rgba(255, 255, 255, 1) 50%,
			rgba(34, 145, 211, 0.7) 60%,
			rgba(20, 114, 202, 0.7) 80%,
			rgba(0, 0, 0, .3) 90%,
			rgba(0, 0, 0,.3) 100%)
		}
		/deep/{
			.el-form-item__content{
				line-height: 5.7vh;
			}
		}
		/deep/{
			.el-input__inner{
				line-height: 5.7vh;
				border: 0;
				background: none;
			}
		}
	}
</style>

